;; -*- coding: utf-8 -*-
;;----------------------------------------------------------------------------
;; Navigate window layouts with "C-c <left>" and "C-c <right>"
;;----------------------------------------------------------------------------
(winner-mode 1)

;;----------------------------------------------------------------------------
;; When splitting window, show (other-buffer) in the new window
;;----------------------------------------------------------------------------
(defun split-window-func-with-other-buffer-vertically ()
    (lambda ()
      (interactive)
      (split-window-vertically)
      (set-window-buffer (next-window) (other-buffer))))

(defun split-window-func-with-other-buffer-horizontally ()
    (lambda ()
      (interactive)
      (split-window-horizontally)
      (set-window-buffer (next-window) (other-buffer))))

(global-set-key (kbd "C-x 2") (split-window-func-with-other-buffer-vertically))
(global-set-key (kbd "C-x 3") (split-window-func-with-other-buffer-horizontally))

;;----------------------------------------------------------------------------
;; splitting window to four, show (other-buffer) in the new window
;;----------------------------------------------------------------------------
(defun split-window-to-four()
  "split current frame to four"
  (interactive)
  (progn
    (split-window-horizontally)
    (set-window-buffer (next-window) (other-buffer))
    (split-window-vertically)
    (set-window-buffer (next-window) (other-buffer))
    (other-window 2)
    (split-window-vertically)
    (set-window-buffer (next-window) (other-buffer))
    (other-window -2)))

(global-set-key (kbd "C-x 4") 'split-window-to-four)


(provide 'init-windows)
